package com.boot.core.test;

import lombok.extern.slf4j.Slf4j;
import org.springframework.context.annotation.Condition;
import org.springframework.context.annotation.ConditionContext;
import org.springframework.core.type.AnnotatedTypeMetadata;

/**
 * @author 霜寒 <1621856595@qq.com>
 * @description 测试环境条件
 * @date 2023/4/21 16:52
 **/
@Slf4j
public class OnTestCondition implements Condition {
    @Override
    public boolean matches(ConditionContext context, AnnotatedTypeMetadata metadata) {
        try {
            Class.forName("org.springframework.test.context.junit.jupiter.SpringExtension");
            log.debug("Spring Load Class: {}", metadata.toString());
            return true;
        } catch (ClassNotFoundException e) {
            log.debug("Spring exclude Class: {}", metadata.toString());
            return false;
        }
    }
}
